//
//  YTStashListModel.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/11/18.
//

#import "YTStashListModel.h"

@implementation YTStashListModel

+ (NSDictionary *)modelCustomPropertyMapper {
    return @{@"ID":@[@"id"],
    };
}

- (CGFloat)nameH{
    if(_nameH == 0){
        _nameH = [DTKTool textWithtitle:self.name andSize:CGSizeMake(kwt(180), 10000) andFout:kCFont(16)].height ;
        if(_nameH < kwt(16)){
            _nameH = kwt(16);
        }
        if(_nameH > kwt(40)){
            _nameH = kwt(40);
        }
    }
    return _nameH;
}
-(CGFloat)CellH{
    return kwt(94) + self.nameH;
}
- (NSString *)stockNumberStr{
    if(!_stockNumberStr){
        _stockNumberStr = [NSString stringWithFormat:@"%lu%@",self.stockNumber,self.normsName];
    }
    return _stockNumberStr;
}
-(NSString *)productNormsStr{
    if(!_productNormsStr){
        _productNormsStr = [NSString stringWithFormat:@"%@/%@",self.productNorms,self.normsName];
    }
    return _productNormsStr;
}

- (CGFloat)stockNumberH{
    if(_stockNumberH == 0){
        _stockNumberH = kwt(16);
    }
    return _stockNumberH;
}
- (CGFloat)categoryNameH{
    if(_categoryNameH == 0){
        _categoryNameH = [DTKTool textWithtitle:self.categoryName andSize:CGSizeMake(kwt(240), 10000) andFout:kFont(16)].height;
        if(_categoryNameH < kwt(16)){
            _categoryNameH = kwt(16);
        }
    }
    return _categoryNameH;
}

- (CGFloat)productNormsStrH{
    if(_productNormsStrH == 0){
        _productNormsStrH = [DTKTool textWithtitle:self.productNormsStr andSize:CGSizeMake(kwt(240), 10000) andFout:kFont(16)].height;
        if(_productNormsStrH < kwt(16)){
            _productNormsStrH = kwt(16);
        }
    }
    return _productNormsStrH;
}
- (CGFloat)areaNameH{
    if(_areaNameH == 0){
        _areaNameH = [DTKTool textWithtitle:self.areaName andSize:CGSizeMake(kwt(240), 10000) andFout:kFont(16)].height;
        if(_areaNameH < kwt(16)){
            _areaNameH = kwt(16);
        }
    }
    return _areaNameH;
}

- (CGFloat)addressNameH{
    if(_addressNameH == 0){
        _addressNameH = [DTKTool textWithtitle:self.addressName andSize:CGSizeMake(kwt(240), 10000) andFout:kFont(16)].height;
        if(_addressNameH < kwt(16)){
            _addressNameH = kwt(16);
        }
    }
    return _addressNameH;
}

- (CGFloat)shelfNumberH{
    if(_shelfNumberH == 0){
        _shelfNumberH = [DTKTool textWithtitle:self.shelfNumber andSize:CGSizeMake(kwt(240), 10000) andFout:kFont(16)].height;
        if(_shelfNumberH < kwt(16)){
            _shelfNumberH = kwt(16);
        }
    }
    return _shelfNumberH;
}
- (CGFloat)BTnameH{
    if(_BTnameH == 0){
        _BTnameH = [DTKTool textWithtitle:self.name andSize:CGSizeMake(kwt(327), 10000) andFout:kCFont(18)].height;
        if(_BTnameH < kwt(16)){
            _BTnameH = kwt(16);
        }
        if(_BTnameH > kwt(45)){
            _BTnameH = kwt(45);
        }
    }
    return _BTnameH;
}
- (CGFloat)DetailsCellH{
    return kwt(12 + 12 + 52 + 16 * 4 + 10 + 16 * 3) + self.BTnameH + self.stockNumberH + self.areaNameH + self.addressNameH + self.shelfNumberH + self.productNormsStrH + self.categoryNameH;
}

- (NSMutableDictionary *)CKDict{
    NSMutableDictionary * dict = [NSMutableDictionary dictionary];
    [dict setObject:self.number forKey:@"number"];
    [dict setObject:self.ID forKey:@"id"];
    return dict;
}
- (NSMutableDictionary *)RKDict{
    NSMutableDictionary * dict = [NSMutableDictionary dictionary];
    [dict setObject:self.number forKey:@"number"];
    [dict setObject:self.ID forKey:@"id"];
    [dict setObject:self.deliveryId forKey:@"deliveryId"];
    [dict setObject:self.deliveryName forKey:@"deliveryName"];
    [dict setObject:self.expiratDate forKey:@"expiratDate"];
    [dict setObject:self.storemanId forKey:@"storemanId"];
    [dict setObject:self.storemanName forKey:@"storemanName"];
    return dict;
}

@end


